package com.wanmait.happyheating.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.happyheating.mapper.ConfigMapper;
import com.wanmait.happyheating.pojo.Config;
import com.wanmait.happyheating.pojo.FaultType;
import com.wanmait.happyheating.pojo.HeatingNumber;
import com.wanmait.happyheating.service.ConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 配置表 服务实现类
 * </p>
 *
 * @author yuQianTao
 * @since 2021-05-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {
    @Resource
    private ConfigMapper configMapper;

    /**
     * 陈宗  2021-06-03
     * 业务逻辑层项配置模糊查询并且分页
     * @param pageNum
     * @param config
     * @return
     */
    @Override
    public PageInfo<Config> findPageConfing(int pageNum, Config config) {
        //实例化条件封装器
        LambdaQueryWrapper<Config> configLambdaQueryWrapper=new LambdaQueryWrapper<>();
        //获得模糊查询的title(配置的项目/比如工作开始结束时间/时间间隔/x时间/默认好评文本)
        configLambdaQueryWrapper.like(Config::getTitle,config.getTitle());
        //设置分页的第几页和每页显示的条数
        PageHelper.startPage(pageNum,3);
        List<Config> configs=configMapper.selectList(configLambdaQueryWrapper);
        //实例化PageInfo
        PageInfo<Config> pageInfo=new PageInfo<>(configs,5);
        return pageInfo;
    }

}
